﻿// See https://aka.ms/new-console-template for more information

//什么是特性？
//特性就是直接或者间接继承Attribute的类

//特性有什么用？
//特性可以提供额外的信息
//特性可以提供额外的功能

using System.Reflection;
using 特性.Attr;
using 特性.Extend;
using 特性.Model;

UserInfo userInfo = new UserInfo()
{
    Id = 1,
    Name = "Test",
    Phone = "123321",
    UserStateEnum = UserStateEnum.Frozen
};

Type type = typeof(UserStateEnum);
FieldInfo filed = type.GetField(userInfo.UserStateEnum.ToString());
var attribute = filed.GetCustomAttribute<Remark>();
string desc = attribute.GetDescription();

var s = userInfo.UserStateEnum.GetType().GetField(userInfo.UserStateEnum.ToString()).GetCustomAttribute<Remark>().GetDescription();

Console.WriteLine(s);
Console.WriteLine(userInfo.UserStateEnum.GetDescription());

Console.WriteLine("Hello, World!");

[CustomerAttrbute("1")]
[CustomerAttrbute("1", 1)]
[CustomerAttrbute()]
[CustomerAttrbute("123", 1, Name = "123")]
[CustomerAttrbute("123", Id = 1, Name = "123")]
internal class obj
{
}